package org.neframework.webtest.interceptor.encode;

import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tmsps.neframework.mvc.annotation.RequestMapping;
import com.tmsps.neframework.mvc.core.NeBaseController;
import com.tmsps.neframework.mvc.web.interceptor.Interceptor;

/**
 * 分页拦截器，定义拦截路径 /cp
 * 
 * @author uninf
 * 
 */
@RequestMapping("/")
public class EncodeInterceptor implements Interceptor {

	@Override
	public boolean before(NeBaseController action, Method method, HttpServletRequest request, HttpServletResponse response) {
		try {
			request.setCharacterEncoding("utf-8");
			response.setCharacterEncoding("utf-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return true;
	}

	@Override
	public boolean after(NeBaseController action, Method method, HttpServletRequest request, HttpServletResponse response) {
		return true;
	}

}
